package org.nterlearning.datamodel.catalog.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import org.nterlearning.datamodel.catalog.model.Contributor;
import org.nterlearning.datamodel.catalog.model.ContributorModel;

import java.io.Serializable;

import java.sql.Types;

/**
 * The base model implementation for the Contributor service. Represents a row in the &quot;CATALOG_Contributor&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link org.nterlearning.datamodel.catalog.model.ContributorModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ContributorImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see ContributorImpl
 * @see org.nterlearning.datamodel.catalog.model.Contributor
 * @see org.nterlearning.datamodel.catalog.model.ContributorModel
 * @generated
 */
public class ContributorModelImpl extends BaseModelImpl<Contributor>
    implements ContributorModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a contributor model instance should use the {@link org.nterlearning.datamodel.catalog.model.Contributor} interface instead.
     */
    public static final String TABLE_NAME = "CATALOG_Contributor";
    public static final Object[][] TABLE_COLUMNS = {
            { "contributorId", Types.BIGINT },
            { "courseId", Types.BIGINT },
            { "componentId", Types.BIGINT },
            { "role", Types.VARCHAR },
            { "contributorName", Types.VARCHAR },
            { "virtualCardData", Types.VARCHAR }
        };
    public static final String TABLE_SQL_CREATE = "create table CATALOG_Contributor (contributorId LONG not null primary key,courseId LONG,componentId LONG,role VARCHAR(50) null,contributorName VARCHAR(200) null,virtualCardData VARCHAR(3999) null)";
    public static final String TABLE_SQL_DROP = "drop table CATALOG_Contributor";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.org.nterlearning.datamodel.catalog.model.Contributor"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.org.nterlearning.datamodel.catalog.model.Contributor"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.org.nterlearning.datamodel.catalog.model.Contributor"),
            true);
    public static long COMPONENTID_COLUMN_BITMASK = 1L;
    public static long COURSEID_COLUMN_BITMASK = 2L;
    public static long ROLE_COLUMN_BITMASK = 4L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.org.nterlearning.datamodel.catalog.model.Contributor"));
    private static ClassLoader _classLoader = Contributor.class.getClassLoader();
    private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
            Contributor.class
        };
    private long _contributorId;
    private long _courseId;
    private long _originalCourseId;
    private boolean _setOriginalCourseId;
    private long _componentId;
    private long _originalComponentId;
    private boolean _setOriginalComponentId;
    private String _role;
    private String _originalRole;
    private String _contributorName;
    private String _virtualCardData;
    private transient ExpandoBridge _expandoBridge;
    private long _columnBitmask;
    private Contributor _escapedModelProxy;

    public ContributorModelImpl() {
    }

    public long getPrimaryKey() {
        return _contributorId;
    }

    public void setPrimaryKey(long primaryKey) {
        setContributorId(primaryKey);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_contributorId);
    }

    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    public Class<?> getModelClass() {
        return Contributor.class;
    }

    public String getModelClassName() {
        return Contributor.class.getName();
    }

    public long getContributorId() {
        return _contributorId;
    }

    public void setContributorId(long contributorId) {
        _contributorId = contributorId;
    }

    public long getCourseId() {
        return _courseId;
    }

    public void setCourseId(long courseId) {
        _columnBitmask |= COURSEID_COLUMN_BITMASK;

        if (!_setOriginalCourseId) {
            _setOriginalCourseId = true;

            _originalCourseId = _courseId;
        }

        _courseId = courseId;
    }

    public long getOriginalCourseId() {
        return _originalCourseId;
    }

    public long getComponentId() {
        return _componentId;
    }

    public void setComponentId(long componentId) {
        _columnBitmask |= COMPONENTID_COLUMN_BITMASK;

        if (!_setOriginalComponentId) {
            _setOriginalComponentId = true;

            _originalComponentId = _componentId;
        }

        _componentId = componentId;
    }

    public long getOriginalComponentId() {
        return _originalComponentId;
    }

    public String getRole() {
        if (_role == null) {
            return StringPool.BLANK;
        } else {
            return _role;
        }
    }

    public void setRole(String role) {
        _columnBitmask |= ROLE_COLUMN_BITMASK;

        if (_originalRole == null) {
            _originalRole = _role;
        }

        _role = role;
    }

    public String getOriginalRole() {
        return GetterUtil.getString(_originalRole);
    }

    public String getContributorName() {
        if (_contributorName == null) {
            return StringPool.BLANK;
        } else {
            return _contributorName;
        }
    }

    public void setContributorName(String contributorName) {
        _contributorName = contributorName;
    }

    public String getVirtualCardData() {
        if (_virtualCardData == null) {
            return StringPool.BLANK;
        } else {
            return _virtualCardData;
        }
    }

    public void setVirtualCardData(String virtualCardData) {
        _virtualCardData = virtualCardData;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public Contributor toEscapedModel() {
        if (_escapedModelProxy == null) {
            _escapedModelProxy = (Contributor) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelProxyInterfaces,
                    new AutoEscapeBeanHandler(this));
        }

        return _escapedModelProxy;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        if (_expandoBridge == null) {
            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
                    Contributor.class.getName(), getPrimaryKey());
        }

        return _expandoBridge;
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        getExpandoBridge().setAttributes(serviceContext);
    }

    @Override
    public Object clone() {
        ContributorImpl contributorImpl = new ContributorImpl();

        contributorImpl.setContributorId(getContributorId());
        contributorImpl.setCourseId(getCourseId());
        contributorImpl.setComponentId(getComponentId());
        contributorImpl.setRole(getRole());
        contributorImpl.setContributorName(getContributorName());
        contributorImpl.setVirtualCardData(getVirtualCardData());

        contributorImpl.resetOriginalValues();

        return contributorImpl;
    }

    public int compareTo(Contributor contributor) {
        long primaryKey = contributor.getPrimaryKey();

        if (getPrimaryKey() < primaryKey) {
            return -1;
        } else if (getPrimaryKey() > primaryKey) {
            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        Contributor contributor = null;

        try {
            contributor = (Contributor) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long primaryKey = contributor.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        ContributorModelImpl contributorModelImpl = this;

        contributorModelImpl._originalCourseId = contributorModelImpl._courseId;

        contributorModelImpl._setOriginalCourseId = false;

        contributorModelImpl._originalComponentId = contributorModelImpl._componentId;

        contributorModelImpl._setOriginalComponentId = false;

        contributorModelImpl._originalRole = contributorModelImpl._role;

        contributorModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<Contributor> toCacheModel() {
        ContributorCacheModel contributorCacheModel = new ContributorCacheModel();

        contributorCacheModel.contributorId = getContributorId();

        contributorCacheModel.courseId = getCourseId();

        contributorCacheModel.componentId = getComponentId();

        contributorCacheModel.role = getRole();

        String role = contributorCacheModel.role;

        if ((role != null) && (role.length() == 0)) {
            contributorCacheModel.role = null;
        }

        contributorCacheModel.contributorName = getContributorName();

        String contributorName = contributorCacheModel.contributorName;

        if ((contributorName != null) && (contributorName.length() == 0)) {
            contributorCacheModel.contributorName = null;
        }

        contributorCacheModel.virtualCardData = getVirtualCardData();

        String virtualCardData = contributorCacheModel.virtualCardData;

        if ((virtualCardData != null) && (virtualCardData.length() == 0)) {
            contributorCacheModel.virtualCardData = null;
        }

        return contributorCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(13);

        sb.append("{contributorId=");
        sb.append(getContributorId());
        sb.append(", courseId=");
        sb.append(getCourseId());
        sb.append(", componentId=");
        sb.append(getComponentId());
        sb.append(", role=");
        sb.append(getRole());
        sb.append(", contributorName=");
        sb.append(getContributorName());
        sb.append(", virtualCardData=");
        sb.append(getVirtualCardData());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBundler sb = new StringBundler(22);

        sb.append("<model><model-name>");
        sb.append("org.nterlearning.datamodel.catalog.model.Contributor");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>contributorId</column-name><column-value><![CDATA[");
        sb.append(getContributorId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>courseId</column-name><column-value><![CDATA[");
        sb.append(getCourseId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>componentId</column-name><column-value><![CDATA[");
        sb.append(getComponentId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>role</column-name><column-value><![CDATA[");
        sb.append(getRole());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>contributorName</column-name><column-value><![CDATA[");
        sb.append(getContributorName());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>virtualCardData</column-name><column-value><![CDATA[");
        sb.append(getVirtualCardData());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
